using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;

namespace OrderingSystem.Core.Entities
{
    [Table("chat")]
    public class Chat
    {
        [Key]
        public long id { get; set; }

        /// <summary>
        /// 添加时间
        /// </summary>
        public DateTime addtime { get; set; }

        /// <summary>
        /// 用户ID
        /// </summary>
        public long userid { get; set; }

        /// <summary>
        /// 管理员ID
        /// </summary>
        public long? adminid { get; set; }

        /// <summary>
        /// 聊天内容
        /// </summary>
        [Column("ask")]
        public string LiaoTianNeiRong { get; set; }

        /// <summary>
        /// 回复内容
        /// </summary>
        public string reply { get; set; }

        /// <summary>
        /// 是否回复
        /// </summary>
        public int? isreply { get; set; } = 0;

        [ForeignKey("userid")]
        public virtual User User { get; set; }

        // 兼容性属性
        [NotMapped]
        [JsonIgnore]
        public long Id { get => id; set => id = value; }

        [NotMapped]
        [JsonIgnore]
        public DateTime AddTime { get => addtime; set => addtime = value; }

        [NotMapped]
        [JsonIgnore]
        public long UserId { get => userid; set => userid = value; }

        [NotMapped]
        [JsonIgnore]
        public string content { get => LiaoTianNeiRong; set => LiaoTianNeiRong = value; }

        [NotMapped]
        [JsonIgnore]
        public string HuiFuNeiRong { get => reply; set => reply = value; }

        [NotMapped]
        [JsonIgnore]
        public string SfHuiFu { get => isreply.ToString(); set => isreply = int.Parse(value); }
    }
} 